package config

import (
	"github.com/BurntSushi/toml"
)

type configStruct struct {
	Environment struct {
		Environment string `toml:"environment"`
	}
	Host struct {
		Host string `toml:"host"`
	}
	Mysql struct {
		MysqlStr string `toml:"mysqlstr"`
	}
	Redis struct {
		Addr     string `toml:"addr"`
		Password string `toml:"password"`
		Db       int    `toml:"db"`
	}
}

func InitConfig() (res *configStruct) {
	fpath := "config.toml"
	configDataStruct := configStruct{}
	_, err := toml.DecodeFile(fpath, &configDataStruct)
	if err != nil {
		return nil
	}
	return &configDataStruct
}
